﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Cloud.Model;
using Cloud.BLL;

public partial class Three_Managerment_Problem_one_Save : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (Session["users"] == null)
            {
                Response.Write("<script>alert('登录超时'); window.parent.location.href='/index.html'</script>");
            }
            if (!IsPostBack)
            {
                Random ran = new Random();
                int RandKey = ran.Next(10000, 99999);
                biaohao.Value = DateTime.Now.ToString("yyyyMMddhhmmsss") + RandKey;
                this.drot.DataSource = SourcesManager.FindAll();
                this.drot.DataTextField = "name";
                this.drot.DataValueField = "id";
                this.drot.DataBind();

                this.guishu.DataSource = AscriptionManager.FindAll();
                this.guishu.DataTextField = "name";
                this.guishu.DataValueField = "id";
                this.guishu.DataBind();

                this.feilei.DataSource = Classification_Appeal1Manager.FindAll();
                this.feilei.DataTextField = "name";
                this.feilei.DataValueField = "id";
                this.feilei.DataBind();

                this.xiaolei.DataSource = Classification_Appeal2Manager.FindBySort(Convert.ToInt32(this.feilei.SelectedItem.Value));
                this.xiaolei.DataTextField = "name";
                this.xiaolei.DataValueField = "id";
                this.xiaolei.DataBind();
            }
        }
        catch (Exception ex)
        {

            Response.Write("<script>alert('登陆信息失效,请重新登陆!'); window.parent.location.href='/index.html'</script>");
            return;
        }
    }
    protected void Unnamed_Click(object sender, EventArgs e)
    {
        try
        {
            if (Session["users"] == null)
            {
                Response.Write("<script>alert('登录超时'); window.parent.location.href='/index.html'</script>");
            }
            Problem activity = new Problem();

            if (rad.Checked)
            {
                activity.Opens = 1;
            }
            else
            {
                activity.Opens = 0;
            }

            if (rad3.Checked)
            {
                activity.Important = 1;
            }
            else
            {
                activity.Important = 0;
            }

            if (rad5.Checked)
            {
                activity.Emergencys = 1;
            }
            else
            {
                activity.Emergencys = 0;
            }

            if (rad7.Checked)
            {
                activity.Repeats = 1;
            }
            else
            {
                activity.Repeats = 0;
            }
            if (rad9.Checked)
            {
                activity.Secrecy = "0";
            }
            else
            {
                activity.Secrecy = "1";
            }

            activity.Appeal_name = this.name.Value;
            activity.Appeal_email = this.email.Value;
            activity.Appeal_tel = this.tel.Value;
            activity.Appeal_type_id = Convert.ToInt32(this.feilei.SelectedItem.Value);
            activity.Appealid = this.biaohao.Value;
            activity.Ascription_id = Convert.ToInt32(this.guishu.SelectedItem.Value);
            activity.Bldwid = "";
            activity.Bm1_type = 9;
            activity.Bm2_type = 9;
            activity.Context = con.Value;
            activity.Current_ld = 0;
            activity.Db_num = 0;
            activity.Handle_type = 0;
            activity.Ischeck = 1;
            activity.Jobnum = Convert.ToInt32(this.num.Value);
            activity.Mp3url = "";
            activity.Regtime = DateTime.Now;
            activity.Reject_num = 0;
            activity.Satisfied = 9;
            activity.Source_id = Convert.ToInt32(this.drot.SelectedItem.Value);
            activity.Title = this.title.Value;
            activity.Xbtime = new DateTime(1900, 01, 01, 00, 00, 00);
            activity.Xialei = Convert.ToInt32(this.xiaolei.SelectedItem.Value);
            activity.Zbtime = new DateTime(1900, 01, 01, 00, 00, 00);
            activity.Zrdwid = "";


            if (ProblemManager.Save(activity) > 0)
            {

                Problem_historic2 his = new Problem_historic2();
                his.Blyj = "";
                his.Title = "录入 ";
                his.Bm2 = "";
                his.Evente = 0;
                his.Idopen = this.biaohao.Value;


                his.Bm1 = ((USER_INFO)Session["users"]).DEPARTMENT;
                his.Item1 = 0;
                his.Item2 = "";
                his.Item3 = "";
                his.Name = ((USER_INFO)Session["users"]).USER_NAME;
                his.Times = DateTime.Now;
                his.Timese = new DateTime(1900, 01, 01, 00, 00, 00);


                Problem_historic2Manager.Save(his);

                Response.Write("<script>alert('上报成功');location.href='index.aspx'</script>");
            }
            else
            {
                Response.Write("<script>alert('上报失败');</script>");
            }
        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('登陆信息失效,请重新登陆!'); window.parent.location.href='/index.html'</script>");
            return;
        }

    }
    protected void feilei_SelectedIndexChanged(object sender, EventArgs e)
    {

        try
        {
            this.xiaolei.DataSource = Classification_Appeal2Manager.FindBySort(Convert.ToInt32(this.feilei.SelectedItem.Value));
            this.xiaolei.DataTextField = "name";
            this.xiaolei.DataValueField = "id";
            this.xiaolei.DataBind();

        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('登陆信息失效,请重新登陆!'); window.parent.location.href='/index.html'</script>");
            return;
        }

    }
}